/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package BusinessLogic;

import DataAccess.DataUtility;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.JOptionPane;

/**
 *
 * @author Nguyen dat
 */
public class ReorganizationExpo {

    /**
     * Reorganization new expo, Exhibitors, product, Booths will be
     * reset status = 0. if reorganization successful then return
     * true else return false
     * @param nameExpo is new name of Expo
     * @return boolean
     */
    public boolean reorganization(String nameExpo) {
        try {
            //call procedure reset Expo
            DataUtility.executeProcedure("resetAll");
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        //
        saveNameExpo(nameExpo);
        return true;
    }

    /**
     * Save name of Expo into file
     * @param nameOfExpo
     */
    public void saveNameExpo(String nameOfExpo) {
        try {
            //Save name new expo into file
            BufferedWriter wr = new BufferedWriter(new FileWriter("NameOfExpo.txt"));
            wr.write(nameOfExpo);

            //show message
            JOptionPane.showMessageDialog(null, "Reorganization successful", "Successful", JOptionPane.INFORMATION_MESSAGE);
            wr.flush();
            wr.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
